/*
 * @Author: chenxuan
 * @Date: 2021-12-16 23:28:40
 * @LastEditTime: 2023-09-18 09:37:08
 * @LastEditors: chenxuan
 */
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HTMLWebpackPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
const envURl = require('./env.js')
const { ModuleFederationPlugin } = require('webpack').container
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin
module.exports = {
  entry: './src/index.js',
  mode: 'production',
  output: {
    // publicPath:'/remotes/dbunit/',
    // path:path.resolve(__dirname,"../../../../../../nginx_MF/container/remotes/dbunit"),
    // filename: '[name].js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          'css-loader'
        ]
      },
      {
        test: /\.less$/,
        use: [
          'style-loader',
          'css-loader',
          'less-loader'
        ]
      },
      {
        test: /\.scss$/,
        use: [
        ]
      },
      // {
      //   test: /\.(eot|svg|ttf|woff|woff2)$/,
      //   loader: 'file-loader'
      // },
      {
        test: /\.(jpg|png|gif|svg)$/,
        loader: 'url-loader',
        options: {
          limit: 12 * 1024,
          esModule: false,
          name: '[hash:10].[ext]'
        },
        type: 'javascript/auto'
      }
    ]
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src/')
    },
    extensions: ['.js', '.vue', '.json', '.index.vue', '.index.js']
  },
  plugins: [
    // 请确保引入这个插件！
    new VueLoaderPlugin(),
    new HTMLWebpackPlugin({
      template: path.resolve(__dirname, './public/index.html')
    }),
    new CopyPlugin({
      patterns: [
        { from: path.resolve(__dirname, 'static'), to: path.resolve(__dirname, './dist/static') }
      ]
    }),
    // new ModuleFederationPlugin({
    //     filename: "file-unit.js",
    //     name: "unit",
    //     library: { type: "var", name: "unit" },
    //     exposes: [
			  //       "./public-path",
    //       {'./Test': "./src/views/test.vue"},
    //       {'Test': "./src/views/test.vue"}
			  //     ]
    //     // shared:['qs','vue','element-ui']
    // }),
    // new BundleAnalyzerPlugin(),
    new webpack.DefinePlugin({
      BASEURL_BASE: JSON.stringify(envURl),
      BASEURL1: 'xxxx',
      RESOK: '000000'
    })
  ]
}
